package com.imcrl.component.page
{
	import starling.events.EventDispatcher;
	
	/**
	 * 抽像分页类;
	 * 
	 *  
	 * 
	 * @author crl
	 * 
	 */	
	public class AbstractPage extends EventDispatcher implements IPageable
	{
		protected var _size:int=1;
		protected var _current:int=0;
		protected var _total:int=0;
		
		
		public function AbstractPage()
		{
		}
		
		/**
		 * 上一页 
		 * 
		 */		
		public function previous():void
		{
			this.current--;
		}
		
		/**
		 * 下一页; 
		 * 
		 */		
		public function next():void
		{
			current++;
		}
		
		/**
		 * 取得每页个数; 
		 * @return 
		 * 
		 */		
		public function get pageSize():uint
		{
			return _size;
		}
		
		public function get dataLength():int{
			return 0;
		}
		
		/**
		 * 设置每页个数 
		 * @param value
		 * 
		 */		
		public function set pageSize(value:uint):void
		{
			_size=value;
		}
		
		/**
		 * 设置当前页码 
		 * @param value
		 * 
		 */		
		public function set current(value:uint):void
		{
			value=Math.max(0,Math.min(value,_total));
			_current=value;
		}
		
		/**
		 * 取得当前页码 
		 * @return 
		 * 
		 */		
		public function get current():uint
		{
			return _current;
		}
		
		
		public function getPageData(pageIndex:int):Array{
			return null;
		}
		
		/**
		 * 取得总页数; 
		 * @return 
		 * 
		 */		
		public function get totalPage():uint
		{
			return _total;
		}
		
		/**
		 * 是否有下一页; 
		 * @return 
		 * 
		 */		
		public function get hasNext():Boolean
		{
			return this._current<this._total;
		}
		
		/**
		 * 是否有上一页; 
		 * @return 
		 * 
		 */		
		public function get hasPrevious():Boolean
		{
			return this._current>1 ;
		}
	}
}